﻿using Abp.Application.Services.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text;
using System.Threading.Tasks;

namespace shenghua.Common.Dto
{
    public class SearchDto: PagedResultRequestDto
    {
        public string Search { get; set; }
        public string SearchTarget { get; set; }

        public DateTime? BeginTime { get; set; }
        public DateTime? EndTime { get; set; }

        public int Page_size { get; set; }
        public int Current_page { get; set; }
        public Dictionary<string, string> Order_by { get; set; }

        public override int MaxResultCount
        {
            get
            {
                return Page_size;
            }
        }

        public override int SkipCount
        {
            get
            {
                return (Current_page - 1) * Page_size;
            }
        }

        public SearchDto()
        {
            Page_size = int.MaxValue;
            Current_page = 1;
        }

        public bool IsOrderByAsc(string name)
        {
            return Order_by.ContainsKey(name) && Order_by[name] == "asc";
        }

        public bool IsOrderByDesc(string name)
        {
            return Order_by.ContainsKey(name) && Order_by[name] == "desc";
        }
    }
}
